package cc.vv.baselibrary.util

import android.os.CountDownTimer

/**
 * 公共倒计时器
 * Created by sun.li on 2018/9/11.
 * @author sun.li
 */
class BaseCountDownTimer :CountDownTimer{

    var timerInterface: CountDownTimerInterface? = null

    /**
     * @param millisInFuture 设置倒计时的总时间（秒）
    * @param countDownInterval 设置每次减去的时间（秒）
     * */
    constructor(millisInFuture :Long,countDownInterval :Long ,timerInterface: CountDownTimerInterface? = null):super(millisInFuture*1000,countDownInterval*1000){
        this.timerInterface = timerInterface
    }

    override fun onFinish() {
        timerInterface?.onFinish()
    }

    override fun onTick(millisUntilFinished: Long) {
        timerInterface?.onTick(millisUntilFinished)
    }

    /** 公共倒计时回调接口*/
    interface CountDownTimerInterface{

        fun onFinish()

        fun onTick(millisUntilFinished: Long)
    }
}